package net.csdn.business.common.enums;

import com.alibaba.fastjson2.JSONObject;
import lombok.AllArgsConstructor;
import lombok.Getter;
import net.csdn.business.common.constant.AuditTypeConstants;

/**
 * @author likun
 * @date 2022/6/30 17:54
 */
public interface AuditEnum {
    @Getter
    @AllArgsConstructor
    enum TypeEnum {
        /**
         * 资源类型
         */
        USER(AuditTypeConstants.USER, "userResourceAuditService","用户"),
        ORG(AuditTypeConstants.ORG, "orgResourceAuditService","组织"),
        ISSUE(AuditTypeConstants.ISSUE, "issueResourceAuditService","issue"),
        COMMENT(AuditTypeConstants.ISSUE_COMMENT, "commentResourceAuditService","issue评论"),
        DISCUSS_CATEGOTY(AuditTypeConstants.DISCUSS_CATEGOTY, "discussCategoryResourceAuditService","discuss分类"),
        DISCUSS_SECTION(AuditTypeConstants.DISCUSS_SECTION, "discussSectionResourceAuditService","discuss分类的分组"),
        DISCUSS(AuditTypeConstants.DISCUSS, "discussResourceAuditService","discuss"),
        DISCUSS_COMMENT(AuditTypeConstants.DISCUSS_COMMENT, "discussCommentResourceAuditService","discuss评论"),
        ALI_REPO(AuditTypeConstants.ALI_REPO, "aliRepoResourceAuditService","代码库"),
        ALI_MR(AuditTypeConstants.ALI_MR, "aliMrResourceAuditService","合并请求"),
        ALI_COMMENT(AuditTypeConstants.ALI_COMMENT, "aliCommentResourceAuditService","代码库评论"),
        ;
        final String code;
        final String instanceName;
        final String describe;

        public static TypeEnum ofCode(String code) {
            for (TypeEnum type : TypeEnum.values()) {
                if (type.code.equalsIgnoreCase(code)) {
                    return type;
                }
            }
            throw new IllegalArgumentException("AuditEnum#TypeEnum param error");
        }
    }

    @Getter
    @AllArgsConstructor
    enum DataTypeEnum {
        /**
         * 数据类型
         */
        JSON_OBJECT(JSONObject.class),
        // JSON_ARRAY(JSONArray.class),
        ;

        private final Class<?> clazz;
    }

    @Getter
    @AllArgsConstructor
    enum AuditStatusEnum {
        /**
         * 资源审核状态
         */
        INIT(0, "初始状态"),
        AUDITING(1, "待审核、审核中"),
        PASS(10, "通过"),
        REVIEW(-10, "复核中"),
        FAIL(-30, "失败"),
        DELETE(-40, "删除"),
        ;
        private final Integer code;
        private final String desc;

        public static AuditStatusEnum ofCode(Integer code) {
            for (AuditStatusEnum auditStatusEnum : AuditStatusEnum.values()) {
                if (auditStatusEnum.code.equals(code)) {
                    return auditStatusEnum;
                }
            }
            throw new IllegalArgumentException("AuditEnum#AuditStatusEnum param error");
        }
    }

    @Getter
    @AllArgsConstructor
    enum AuditStrategyEnum {
        /**
         * 审核策略
         */
        SEND_FIRST(1, "先发后审"),
        AUDIT_FIRST(2, "先审后发"),
        TIME_SPLIT(3, "分时段执行（0点-9点）"),
        ;
        private final int code;
        private final String desc;

    }

    // @Getter
    // @AllArgsConstructor
    // enum ActionEnum {
    //     /**
    //      * 资源操作类型
    //      */
    //     CREATE(1, "新增"),
    //     UPDATE(2, "更新"),
    //     DELETE(3, "删除"),
    //     ;
    //     final int code;
    //     final String desc;
    // }
}